package com.iims.flowable.service;

import com.iims.common.core.domain.AjaxResult;
import com.iims.flowable.flow.domain.FlowableCategory;
import com.iims.flowable.flow.vo.request.FlowActiveSuspendRequest;
import org.flowable.engine.repository.ProcessDefinition;
import org.springframework.core.io.InputStreamSource;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @author fanpei
 * @date 2021-04-03 14:41
 */
public interface IFlowDefinitionService {

    /**
     * 查询单一流程定义
     *
     * @param processDefinitionId
     * @return
     */
    ProcessDefinition getProcessDefinitionById(String processDefinitionId);

    /**
     * 所有流程分类列表
     *
     * @return
     */
    List<FlowableCategory> categoryList();

    /**
     * 导入流程文件
     */
    AjaxResult importFile(String name, String category, String filename, InputStreamSource file, HttpServletRequest request);

    /**
     * 读取xml
     *
     * @param processDefinitionId
     * @return
     */
    AjaxResult readXml(String processDefinitionId) throws IOException;

    /**
     * 激活流程定义
     *
     * @param actionRequest
     */
    void activate(FlowActiveSuspendRequest actionRequest);

    /**
     * 挂起流程定义
     *
     * @param actionRequest
     */
    void suspend(FlowActiveSuspendRequest actionRequest);


    /**
     * 删除流程定义
     *
     * @param processDefinitionId 流程定义Id
     * @param cascade             是否允许级联删除
     */
    void delete(String processDefinitionId, boolean cascade);


    /**
     * 读取图片文件
     *
     * @param processDefinitionId
     * @return
     */
    InputStream readImage(String processDefinitionId);
}
